//
//  WYWRefreshGifFooter.m
//  15WClient
//
//  Created by JinYong on 16/5/9.
//  Copyright © 2016年 15w. All rights reserved.
//

#import "WYWRefreshGifFooter.h"
static const NSTimeInterval kFooterTimeInterval = 0.4f;

@implementation WYWRefreshGifFooter
- (void)prepare
{
    [super prepare];
    
    self.backgroundColor = [UIColor clearColor];
    
    //获取动画数组
    NSMutableArray *refreshingImages = [NSMutableArray array];
    for (NSUInteger i = 1; i<=16; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"f_loading_%0.2ld", (unsigned long)i]];
        [refreshingImages addObject:image];
    }
    
    //闲置
    UIImage *image = [UIImage imageNamed:@"f_loading_00"];
    [self setImages:@[image] duration:kFooterTimeInterval forState:MJRefreshStateIdle];
    //松开就可以进行刷新
    [self setImages:refreshingImages duration:kFooterTimeInterval forState:MJRefreshStatePulling];
    //刷新中
    [self setImages:refreshingImages duration:kFooterTimeInterval forState:MJRefreshStateRefreshing];

    [self setImages:@[] duration:kFooterTimeInterval forState:MJRefreshStateNoMoreData];
    
    [self setTitle:@"" forState:MJRefreshStateIdle];
    [self setTitle:@"  正在加载..." forState:MJRefreshStatePulling];
    [self setTitle:@"  正在加载..." forState:MJRefreshStateRefreshing];
    [self setTitle:@"  正在加载..." forState:MJRefreshStateWillRefresh];
    [self setTitle:@"一  没有更多内容  一" forState:MJRefreshStateNoMoreData];
    
    self.stateLabel.textColor = UIColorFromHex(0x999999);
    self.stateLabel.font = fontWithPingfang(15);
    self.stateLabel.numberOfLines = 0;
    [self.stateLabel sizeToFit];
}

- (void)placeSubviews
{
    [super placeSubviews];
    self.gifView.contentMode = UIViewContentModeCenter;
    self.gifView.center = CGPointMake(self.mj_w * 0.5 - 55, self.mj_h * 0.5);
}


@end
